package com.liu.auto.token;

import com.auth0.jwt.JWT;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

@AutoConfiguration //声明为配置类
@ConditionalOnClass(JWT.class) //条件判断 有JWT这个类才生效
@EnableConfigurationProperties({TokenProperties.class}) //属性绑定类
@ConditionalOnProperty(prefix = "token",value = "enabled",matchIfMissing = true) //开关，配置了enabled属性按照配置的，没有就按matchMissing=true
public class TokenAutoConfiguration {


    @Bean
    @ConditionalOnMissingBean
    public TokenTemplate tokenTemplate(){
        return new TokenTemplate();
    }



}
